/********************************************************************************
 *      Copyright:  (C) 2022 Nikel
 *                  All rights reserved.
 *
 *       Filename:  mosquitto.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(28/04/22)
 *         Author:  zhouyanlin <www.zhouyanlin1222@qq.com>
 *      ChangeLog:  1, Release initial version on "28/04/22 15:43:36"
 *                 
 ********************************************************************************/

	
#ifndef  _MSQT_H_
#define  _MSQT_H_


#include <mosquitto.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cJSON.h>

#include "ds18b20.h"

typedef struct mqtt_s
{
	    const char    			*host;
		const char    			*username;
	    const char    			*passward;
		const char    			*topic;
		const char    			*clientid;
		int     	   			port;
		int 					platform;
		struct mosquitto 	  	*mosq;

} mqtt_ctx_t;

int mosquitto_init(mqtt_ctx_t *msqt_ctx);


void my_connect_callback(struct mosquitto *mosq, void *userdata, int result);

void my_log_callback(struct mosquitto *mosq, void *userdata, int level, const char *str);


void on_publish(struct mosquitto *mosq, void *obj, int reason_code);

void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_message *msg);

void on_subscribe(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos);

void on_disconnect(struct mosquitto *mosq, void *obj, int rc);

#endif   /* ----- #ifndef _MOSQUITTO_H_  ----- */
